/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.clemson.cs.hamptos.adventure;

import java.util.HashMap;

/**
 *
 * @author Nicks
 */
public class VerbPick implements VerbStrategy {
    @Override
    public void doCommand(AdventureCommand c, AdventureEngine e, AdventureWindow w) {
        AdventureTarget theio = c.getIndirectObject();
        
        if ((theio == null)||(c.getDirectObject() != null))
        {
            w.println("Pick up what again?");
            return;
        }
        
        HashMap<String, Integer> iostats = theio.getStats();
        
        if (iostats.containsKey("enabled"))
        {
            if (iostats.get("enabled") == 0)
            {
                return;
            }
        }
        
        if (!(iostats.containsKey("portable")))
        {
            w.println("You can't " + c.getVerb() + " " + theio.getShortDescription());
            return;
        }
        else if (!(iostats.get("portable") == 1))
        {
            w.println("You can't " + c.getVerb() + " up " + theio.getShortDescription());
            return;
        }
        try
        {
            e.addToPlayerInventory(theio);
            w.println("You picked up " + theio.getShortDescription());
        }
        catch (IllegalStateException ex)
        {
            w.println(ex.getMessage());
        }
    }
}
